package com.lagou.work.task03.angel.jobService.impl.test;

public class BubbleSort {

    public String sort(String inputData){
        String[] arr = inputData.split("\t");
        //冒泡排序
        for(int i = 0;i < arr.length-1;i++){
            for(int j = 0;j <arr.length-1-i;j++){
                if(Integer.valueOf(arr[j]) >Integer.valueOf(arr[j+1])){
                    int temp = Integer.valueOf(arr[j]);
                    arr[j] = arr[j+1];
                    arr[j+1] = String.valueOf(temp);
                }
            }
        }
        return this.toString(arr);
}

    public String toString(String[] sortResult) {
        StringBuffer strBuffer = new StringBuffer();
        for (String i : sortResult) {
            strBuffer.append(i).append("\t");
        }
        return strBuffer.toString().trim();
    }
}
